package p270jp.pxv.android.legacy.model;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import java.util.List;
import p023an.Intrinsics;
import p047bg.C1124a;
import p104de.greenrobot.dao.query.QueryBuilder;
import p104de.greenrobot.dao.query.WhereCondition;
import p270jp.pxv.android.legacy.model.EmojiDao;
import p325m0.MutabilityOwnership;
import p501sn.AbstractC6052b0;
import p603wm.Unit;
import p681zm.Continuation;

/* compiled from: EmojiDaoManager.kt */
/* renamed from: jp.pxv.android.legacy.model.EmojiDaoManager */
/* loaded from: classes2.dex */
public final class EmojiDaoManager {
    private final DaoManager daoManager;
    private final AbstractC6052b0 ioDispatcher;

    public EmojiDaoManager(DaoManager daoManager, AbstractC6052b0 b0Var) {
        MutabilityOwnership.m3745m(daoManager, "daoManager");
        MutabilityOwnership.m3745m(b0Var, "ioDispatcher");
        this.daoManager = daoManager;
        this.ioDispatcher = b0Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:10:0x0021  */
    /* JADX WARN: Removed duplicated region for block: B:14:0x002f  */
    /* Code decompiled incorrectly, please refer to instructions dump */
    public final java.lang.Object emojiList(p681zm.Continuation<? super java.util.List<? extends p270jp.pxv.android.legacy.model.Emoji>> r6) {
        /*
            r5 = this;
            boolean r0 = r6 instanceof p270jp.pxv.android.legacy.model.EmojiDaoManager$emojiList$1
            if (r0 == 0) goto L_0x0013
            r0 = r6
            jp.pxv.android.legacy.model.EmojiDaoManager$emojiList$1 r0 = (p270jp.pxv.android.legacy.model.EmojiDaoManager$emojiList$1) r0
            int r1 = r0.label
            r2 = -2147483648(0xffffffff80000000, float:-0.0)
            r3 = r1 & r2
            if (r3 == 0) goto L_0x0013
            int r1 = r1 - r2
            r0.label = r1
            goto L_0x0018
        L_0x0013:
            jp.pxv.android.legacy.model.EmojiDaoManager$emojiList$1 r0 = new jp.pxv.android.legacy.model.EmojiDaoManager$emojiList$1
            r0.<init>(r6)
        L_0x0018:
            java.lang.Object r6 = r0.result
            an.a r1 = p023an.Intrinsics.COROUTINE_SUSPENDED
            int r2 = r0.label
            r3 = 1
            if (r2 == 0) goto L_0x002f
            if (r2 != r3) goto L_0x0027
            p060c2.Chain.m9951I(r6)
            goto L_0x0043
        L_0x0027:
            java.lang.IllegalStateException r6 = new java.lang.IllegalStateException
            java.lang.String r0 = "call to 'resume' before 'invoke' with coroutine"
            r6.<init>(r0)
            throw r6
        L_0x002f:
            p060c2.Chain.m9951I(r6)
            sn.b0 r6 = r5.ioDispatcher
            jp.pxv.android.legacy.model.EmojiDaoManager$emojiList$2 r2 = new jp.pxv.android.legacy.model.EmojiDaoManager$emojiList$2
            r4 = 0
            r2.<init>(r5, r4)
            r0.label = r3
            java.lang.Object r6 = p047bg.C1124a.m10192V(r6, r2, r0)
            if (r6 != r1) goto L_0x0043
            return r1
        L_0x0043:
            java.lang.String r0 = "suspend fun emojiList():…  .list()\n        }\n    }"
            p325m0.MutabilityOwnership.m3746l(r6, r0)
            return r6
        */
        throw new UnsupportedOperationException("Method not decompiled: p270jp.pxv.android.legacy.model.EmojiDaoManager.emojiList(zm.d):java.lang.Object");
    }

    public final Bitmap getEmoji(String str) {
        byte[] image;
        QueryBuilder<Emoji> queryBuilder = this.daoManager.getReadableSession().getEmojiDao().queryBuilder();
        queryBuilder.m7238j(EmojiDao.Properties.Slug.m7284a(str), new WhereCondition[0]);
        List<Emoji> f = queryBuilder.m7242f();
        if (f.size() > 0 && (image = f.get(0).getImage()) != null) {
            if (!(image.length == 0)) {
                return BitmapFactory.decodeByteArray(image, 0, image.length);
            }
        }
        return null;
    }

    public final Object refresh(List<? extends Emoji> list, Continuation<? super Unit> dVar) {
        Object V = C1124a.m10192V(this.ioDispatcher, new EmojiDaoManager$refresh$2(this, list, null), dVar);
        return V == Intrinsics.COROUTINE_SUSPENDED ? V : Unit.f29503a;
    }
}
